﻿using System;
using System.ComponentModel.DataAnnotations;
using easyVal.ServerSide;

namespace easyVal.ValidationAttributes
{
    public class NotNullOrEmptyStringAttribute : ValidationAttribute, IClientValidationMethod
    {
        #region IClientValidationMethod Members

        public string ClientMethodName
        {
            get { return "notNullOrEmptyString"; }
        }

        public string ClientParameters
        {
            get { return null; }
        }

        #endregion

        public override bool IsValid(object value)
        {
            if (value == null)
                return false;

            if (value.ToString() == string.Empty)
                return false;

            return true;
        }
    }
}